package per.yhh.xxxtsj.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import per.yhh.xxxtsj.entity.Category;
import per.yhh.xxxtsj.entity.Message;
import per.yhh.xxxtsj.service.CategoryService;

import java.io.Console;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yhh
 * @since 2022-04-10
 */
@CrossOrigin
@RestController
@RequestMapping("/category")
public class CategoryController {
    final
    CategoryService categoryService;

    public CategoryController(CategoryService categoryService) {
        this.categoryService = categoryService;
    }

    @PostMapping("/addcategory")
    public Message addCategory(@RequestBody Category category){
        System.out.println(category);
        if(categoryService.addCateGory(category)){
            return Message.ok(null);
        }
        return Message.failed();
    }
}

